class Student:

    def __init__(self, name, age):
        self.name = name  # self.name 实例属性
        self.age = age

    def eat(self):
        print(self.name + '在吃饭')


stu1 = Student('zs', 20)
stu2 = Student('ls', 30)

print('-------------为stu1动态绑定属性：性别-----------------')
stu1.gender = '女'
print(stu1.name, stu1.age, stu1.gender)
# print(stu2.name, stu2.age, stu2.gender)  # error stu2没有gender

print('-------------为stu2动态绑定方法-----------------')


def show():
    print('定义在类之外的，称函数')


stu2.show = show
stu2.show()
